<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<template id="tp1">
  <div>
    子组件
  </div>
</template>

<div id="app">
  <cpn ref="a"></cpn>
  <cpn ref="b"></cpn>
  <cpn ref="c"></cpn>
  <cpn ref="d"></cpn>
  <button @click="btnclick">$chilrdren</button>
  <button @click="breclick">$refs</button>
</div>

<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el:"#app",
    data: {
      message:"stupid mother fucker",
    },
    components:{
      cpn:{
        template:'#tp1',
        data(){
          return{name:'子组件的name'}
        },
        methods:{
          fuck(){
            console.log('fuckuletherman');
          }
        }

      }
    },
    methods:{
      btnclick(){
        console.log(this.$children);
        console.log(this.$children[0].fuck())
        console.log(this.$children[0].name)
      },
      breclick(){
        console.log(this.$refs.a.fuck());
        console.log(this.$refs.a.name);
      }
    }
  })
</script>

</body>
</html>